<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>2025程序设计天梯赛补题报告 | Sevin的小窝</title><meta name="keywords" content="题目"><meta name="author" content="Sevin"><meta name="copyright" content="Sevin"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="2025程序设计天梯赛补题报告，L1 L2部分">
<meta property="og:type" content="article">
<meta property="og:title" content="2025程序设计天梯赛补题报告">
<meta property="og:url" content="https://blog.sevin.cn/posts/58365/index.html">
<meta property="og:site_name" content="Sevin的小窝">
<meta property="og:description" content="2025程序设计天梯赛补题报告，L1 L2部分">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://api.sevin.cn/api/img/ecy/%20(149).jpg">
<meta property="article:published_time" content="2025-05-16T22:33:40.000Z">
<meta property="article:modified_time" content="2025-07-07T09:39:46.439Z">
<meta property="article:author" content="Sevin">
<meta property="article:tag" content="题目">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://api.sevin.cn/api/img/ecy/%20(149).jpg"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://blog.sevin.cn/posts/58365/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta name="google-site-verification" content="gzenv5Dy9Dwe2fxxkarrJcNmN3FTFrenAmlns4dNg7o"/><meta name="baidu-site-verification" content="code-RhDOYEYqZn"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?996684846661df540f0abcc7f141c225";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><link rel="stylesheet" href="/Sevin" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: Sevin","link":"链接: ","source":"来源: Sevin的小窝","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"bottom-left"},
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '2025程序设计天梯赛补题报告',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2025-07-07 09:39:46'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script><script>LA.init({id:"JwLxjAba3D2cfbQE",ck:"JwLxjAba3D2cfbQE"})</script><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-swiper/swiper/swiper.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-swiper/swiper/swiperstyle.css"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 6.2.0"><link rel="alternate" href="/feed.xml" title="Sevin的小窝" type="application/rss+xml">
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://q.qlogo.cn/g?b=qq&amp;nk=2720269770&amp;s=640" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">42</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">36</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);" rel="external nofollow noreferrer"><i class="fa-fw fas fa-list"></i><span> 其他</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/mytools/"><i class="fa-fw fa-solid fa-toolbox"></i><span> 我的工具页</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" target="_blank" rel="noopener external nofollow noreferrer" href="https://home.sevin.cn"><i class="fa-fw fa-solid fa-house-user"></i><span> 主页</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://api.sevin.cn/api/img/ecy/%20(149).jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Sevin的小窝</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);" rel="external nofollow noreferrer"><i class="fa-fw fas fa-list"></i><span> 其他</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/mytools/"><i class="fa-fw fa-solid fa-toolbox"></i><span> 我的工具页</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" target="_blank" rel="noopener external nofollow noreferrer" href="https://home.sevin.cn"><i class="fa-fw fa-solid fa-house-user"></i><span> 主页</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">2025程序设计天梯赛补题报告</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2025-05-16T22:33:40.000Z" title="发表于 2025-05-16 22:33:40">2025-05-16</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2025-07-07T09:39:46.439Z" title="更新于 2025-07-07 09:39:46">2025-07-07</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/ACM/">ACM</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">3.5k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>14分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="2025程序设计天梯赛补题报告"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span><span class="post-meta-separator">|</span><span class="post-meta-commentcount"><i class="far fa-comments fa-fw post-meta-icon"></i><span class="post-meta-label">评论数:</span><a href="/posts/58365/#post-comment"><span class="gitalk-comment-count"><i class="fa-solid fa-spinner fa-spin"></i></span></a></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="2025程序设计天梯赛补题报告"><a href="#2025程序设计天梯赛补题报告" class="headerlink" title="2025程序设计天梯赛补题报告"></a>2025程序设计天梯赛补题报告</h1><p>仅包含L1 L2</p>
<h2 id="L1-6-这不是字符串题"><a href="#L1-6-这不是字符串题" class="headerlink" title="L1-6 这不是字符串题"></a>L1-6 这不是字符串题</h2><h3 id="题目描述"><a href="#题目描述" class="headerlink" title="题目描述"></a>题目描述</h3><p>因为每年天梯赛字符串题的解答率都不尽如人意，因此出题组从几年前开始决定：每年的天梯赛的 15 分一定会有一道字符串题，另外一道则一定不是字符串题。</p>
<p>小特现在有 <em>N</em> 个正整数 $A_i$，不知道为什么，小特打算”动”一下这些数字。具体而言，她希望做 <em>M</em> 次操作，每次是以下三种操作之一：</p>
<ol>
<li>在当前正整数序列里查找给定的连续正整数序列是否存在，如存在，则将其替换成另外一个正整数序列；</li>
<li>对于当前整个正整数序列，如果相邻之间的数字和为偶数，则在它们中间插入它们的平均数；</li>
<li>翻转当前正整数序列指定下标之间的一段数字。这里的翻转指的是对于一段数字序列 $A_i$,$A_{i+1}$,…,$A_{j-1}$,$A_j$，将其变为 $A_j$,$A_{j-1}$,…,$A_{i+1}$,$A_i$。</li>
</ol>
<p>请你输出按输入顺序依次完成若干次操作后的结果。</p>
<h3 id="求解思路"><a href="#求解思路" class="headerlink" title="求解思路"></a>求解思路</h3><p>可选2种数据结构维护：</p>
<ul>
<li>vector</li>
<li>string<br>这里挺有意思的，因为数值大小是1-26所以可以用字符来代替数字</li>
</ul>
<p>以下是vector的2个在本题涉及的方法</p>
<h4 id="insert"><a href="#insert" class="headerlink" title="insert"></a><code>insert</code></h4><ol>
<li><p><strong>插入单个元素</strong>：</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="function">iterator <span class="title">insert</span><span class="params">(iterator pos, <span class="type">const</span> T&amp; value)</span></span>;</span><br></pre></td></tr></table></figure>

<ul>
<li><code>pos</code>：插入位置的迭代器。</li>
<li><code>value</code>：要插入的元素。</li>
</ul>
</li>
<li><p><strong>插入多个相同元素</strong>：</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="function">iterator <span class="title">insert</span><span class="params">(iterator pos, size_type count, <span class="type">const</span> T&amp; value)</span></span>;</span><br></pre></td></tr></table></figure>

<ul>
<li><code>pos</code>：插入位置的迭代器。</li>
<li><code>count</code>：插入元素的数量。</li>
<li><code>value</code>：要插入的元素。</li>
</ul>
</li>
<li><p><strong>插入范围内的元素</strong>：</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">template</span>&lt;<span class="keyword">class</span> InputIt&gt;</span></span><br><span class="line"><span class="function">iterator <span class="title">insert</span><span class="params">(iterator pos, InputIt first, InputIt last)</span></span>;</span><br></pre></td></tr></table></figure>

<ul>
<li><code>pos</code>：插入位置的迭代器。</li>
<li><code>first</code>：要插入的起始迭代器。</li>
<li><code>last</code>：要插入的结束迭代器。</li>
</ul>
</li>
<li><p><strong>插入初始化列表中的元素</strong>：</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="function">iterator <span class="title">insert</span><span class="params">(iterator pos, std::initializer_list&lt;T&gt; ilist)</span></span>;</span><br></pre></td></tr></table></figure>

<ul>
<li><code>pos</code>：插入位置的迭代器。</li>
<li><code>ilist</code>：包含要插入元素的初始化列表。</li>
</ul>
</li>
</ol>
<h4 id="erase"><a href="#erase" class="headerlink" title="erase"></a><code>erase</code></h4><ol>
<li><p><strong>删除单个元素</strong>：</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="function">iterator <span class="title">erase</span><span class="params">(iterator pos)</span></span>;</span><br></pre></td></tr></table></figure>

<ul>
<li><code>pos</code>：要删除的元素的迭代器。</li>
</ul>
</li>
<li><p><strong>删除范围内的元素</strong>：</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="function">iterator <span class="title">erase</span><span class="params">(iterator first, iterator last)</span></span>;</span><br></pre></td></tr></table></figure>

<ul>
<li><code>first</code>：要删除的起始迭代器。</li>
<li><code>last</code>：要删除的结束迭代器。</li>
</ul>
</li>
</ol>
<h3 id="实现代码"><a href="#实现代码" class="headerlink" title="实现代码"></a>实现代码</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;bits/stdc++.h&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"><span class="keyword">typedef</span> <span class="type">long</span> <span class="type">long</span> LL;</span><br><span class="line"></span><br><span class="line">LL n, m;</span><br><span class="line">vector&lt;LL&gt; a;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</span><br><span class="line">	cin &gt;&gt; n &gt;&gt; m;</span><br><span class="line">	<span class="keyword">for</span> (LL i = <span class="number">0</span>; i &lt; n; i++) &#123;</span><br><span class="line">		LL t;</span><br><span class="line">		cin &gt;&gt; t;</span><br><span class="line">		a.<span class="built_in">push_back</span>(t);</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	<span class="keyword">while</span> (m--) &#123;</span><br><span class="line">		LL k;</span><br><span class="line">		cin &gt;&gt; k;</span><br><span class="line">		<span class="keyword">if</span> (k == <span class="number">1</span>) &#123;</span><br><span class="line">			LL L1, L2;</span><br><span class="line">			cin &gt;&gt; L1;</span><br><span class="line">			vector&lt;LL&gt; a1, a2;</span><br><span class="line">			<span class="keyword">for</span> (LL i = <span class="number">0</span>; i &lt; L1; i++) &#123;</span><br><span class="line">				LL t;</span><br><span class="line">				cin &gt;&gt; t;</span><br><span class="line">				a1.<span class="built_in">push_back</span>(t);</span><br><span class="line">			&#125;</span><br><span class="line">			cin &gt;&gt; L2;</span><br><span class="line">			<span class="keyword">for</span> (LL i = <span class="number">0</span>; i &lt; L2; i++) &#123;</span><br><span class="line">				LL t;</span><br><span class="line">				cin &gt;&gt; t;</span><br><span class="line">				a2.<span class="built_in">push_back</span>(t);</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">for</span> (LL i = <span class="number">0</span>; i &lt; a.<span class="built_in">size</span>() - L1 + <span class="number">1</span>; i++) &#123;</span><br><span class="line">				LL flag = <span class="number">1</span>;</span><br><span class="line">				<span class="keyword">for</span> (LL j = <span class="number">0</span>, now = i; j &lt; a1.<span class="built_in">size</span>(); j++, now ++) &#123;</span><br><span class="line">					<span class="keyword">if</span> (a[now] != a1[j]) &#123;</span><br><span class="line">						flag = <span class="number">0</span>;</span><br><span class="line">						<span class="keyword">break</span>;</span><br><span class="line">					&#125;</span><br><span class="line">				&#125;</span><br><span class="line">				<span class="keyword">if</span> (flag) &#123; <span class="comment">// 找到了</span></span><br><span class="line">					a.<span class="built_in">erase</span>(a.<span class="built_in">begin</span>() + i, a.<span class="built_in">begin</span>() + i + L1);</span><br><span class="line">					a.<span class="built_in">insert</span>(a.<span class="built_in">begin</span>() + i, a2.<span class="built_in">begin</span>(), a2.<span class="built_in">end</span>());</span><br><span class="line">					<span class="keyword">break</span>;</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">else</span> <span class="keyword">if</span> (k == <span class="number">2</span>) &#123;</span><br><span class="line">			vector&lt;LL&gt; t;</span><br><span class="line">			<span class="keyword">for</span> (LL i = <span class="number">0</span>; i &lt;a.<span class="built_in">size</span>() - <span class="number">1</span>; i++) &#123;</span><br><span class="line">				t.<span class="built_in">push_back</span>(a[i]);</span><br><span class="line">				<span class="keyword">if</span> ((a[i] + a[i + <span class="number">1</span>]) % <span class="number">2</span> == <span class="number">0</span>) t.<span class="built_in">push_back</span>((a[i] + a[i + <span class="number">1</span>]) / <span class="number">2</span>);</span><br><span class="line">			&#125;</span><br><span class="line">			t.<span class="built_in">push_back</span>(a.<span class="built_in">back</span>());</span><br><span class="line">			a= t;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">else</span> <span class="keyword">if</span> (k == <span class="number">3</span>) &#123;</span><br><span class="line">			LL l, r;</span><br><span class="line">			cin &gt;&gt; l &gt;&gt; r;</span><br><span class="line">			l--, r--;</span><br><span class="line">			<span class="built_in">reverse</span>(a.<span class="built_in">begin</span>() + l, a.<span class="built_in">begin</span>() + r + <span class="number">1</span>);</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	<span class="keyword">for</span> (LL i = <span class="number">0</span>; i &lt; a.<span class="built_in">size</span>(); i++) &#123;</span><br><span class="line">		cout &lt;&lt; a[i];</span><br><span class="line">		<span class="keyword">if</span> (i != a.<span class="built_in">size</span>() - <span class="number">1</span>) cout &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="L1-7-大幂数"><a href="#L1-7-大幂数" class="headerlink" title="L1-7 大幂数"></a>L1-7 大幂数</h2><h3 id="题目描述-1"><a href="#题目描述-1" class="headerlink" title="题目描述"></a>题目描述</h3><p>如果一个正整数可以表示为从 1 开始的连续自然数的非 0 幂次和，就称之为“大幂数”。例如 2025 就是一个大幂数，因为 2025&#x3D;1^3^+2^3^+3^3^+4^3^+5^3^+6^3^+7^3^+8^3^+9^3^。本题就请你判断一个给定的数字 <em>n</em> 是否大幂数，如果是，就输出其幂次和。</p>
<p>另一方面，大幂数的幂次和表示可能是不唯一的，例如 91 可以表示为 9^1^&#x3D;1^1^+2^1^+3^1^+4^1^+5^1^+6^1^+7^1^+8^1^+9^1^+10^1^+11^1^+12^1^+13^1^，同时也可以表示为 9^1^&#x3D;1^2^+2^2^+3^2^+4^2^+5^2^+6^2^，这时你只需要输出幂次最大的那个和即可。</p>
<h3 id="求解思路-1"><a href="#求解思路-1" class="headerlink" title="求解思路"></a>求解思路</h3><h3 id="实现代码-1"><a href="#实现代码-1" class="headerlink" title="实现代码"></a>实现代码</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;bits/stdc++.h&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"><span class="keyword">typedef</span> <span class="type">long</span> <span class="type">long</span> LL;</span><br><span class="line"><span class="type">const</span> <span class="type">int</span> N = <span class="number">1e5</span>;</span><br><span class="line"></span><br><span class="line">LL n;</span><br><span class="line">LL a[N][<span class="number">40</span>];</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</span><br><span class="line">	cin &gt;&gt; n;</span><br><span class="line">	</span><br><span class="line">	<span class="keyword">if</span> (n == <span class="number">1</span>) &#123;</span><br><span class="line">		cout &lt;&lt; <span class="string">&quot;1^1&quot;</span>;</span><br><span class="line">		<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	<span class="keyword">for</span> (LL j = <span class="number">1</span>; j &lt;= <span class="number">31</span>; j++) &#123; <span class="comment">// 预处理</span></span><br><span class="line">		<span class="keyword">for</span> (LL i = <span class="number">1</span>; i &lt; N; i++) &#123;</span><br><span class="line">			a[i][j] = a[i - <span class="number">1</span>][j] + <span class="built_in">pow</span>(i, j);</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	<span class="keyword">for</span> (LL j = <span class="number">31</span>; j &gt;= <span class="number">1</span>; j--) &#123;</span><br><span class="line">		<span class="keyword">for</span> (LL i = <span class="number">1</span>; i &lt; N; i++) &#123;</span><br><span class="line">			<span class="keyword">if</span> (a[i][j] == n) &#123;</span><br><span class="line">				<span class="keyword">for</span> (LL x = <span class="number">1</span>; x &lt;= i; x++) &#123;</span><br><span class="line">					<span class="keyword">if</span> (x != <span class="number">1</span>) cout &lt;&lt; <span class="string">&quot;+&quot;</span>;</span><br><span class="line">					cout &lt;&lt; x &lt;&lt; <span class="string">&quot;^&quot;</span> &lt;&lt; j;</span><br><span class="line">				&#125;</span><br><span class="line">				<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">else</span> <span class="keyword">if</span> (a[i][j] &gt; n) <span class="keyword">break</span>;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125; </span><br><span class="line">	</span><br><span class="line">	cout &lt;&lt; <span class="string">&quot;Impossible for &quot;</span> &lt;&lt; n &lt;&lt; <span class="string">&quot;.&quot;</span>;</span><br><span class="line">	</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="L2-1-算式拆解"><a href="#L2-1-算式拆解" class="headerlink" title="L2-1 算式拆解"></a>L2-1 算式拆解</h2><h3 id="题目描述-2"><a href="#题目描述-2" class="headerlink" title="题目描述"></a>题目描述</h3><p>括号用于改变算式中部分计算的默认优先级，例如 2+3×4&#x3D;14，因为乘法优先级高于加法；但 (2+3)×4&#x3D;20，因为括号的存在使得加法先于乘法被执行。本题请你将带括号的算式进行拆解，按执行顺序列出各种操作。</p>
<p>注意：题目只考虑 <code>+</code>、<code>-</code>、<code>*</code>、<code>/</code> 四种操作，且输入保证每个操作及其对应的两个操作对象都被一对圆括号 <code>()</code> 括住，即算式的通用格式为 <code>(对象 操作 对象)</code>，其中 <code>对象</code> 可以是数字，也可以是另一个算式。</p>
<h3 id="求解思路-2"><a href="#求解思路-2" class="headerlink" title="求解思路"></a>求解思路</h3><p>这题非常眼熟，在学习stack的时候就学过类似的。反正其实就是一道简单的stack题，当时比赛没写出来还是因为思维不够清晰，应该多训练，这样以后就能对题目的意思更加敏感，就不会写不出。</p>
<h3 id="实现代码-2"><a href="#实现代码-2" class="headerlink" title="实现代码"></a>实现代码</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;bits/stdc++.h&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"><span class="keyword">typedef</span> <span class="type">long</span> <span class="type">long</span> LL;</span><br><span class="line"></span><br><span class="line">stack&lt;<span class="type">char</span>&gt; s;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</span><br><span class="line">	string str;</span><br><span class="line">	<span class="built_in">getline</span>(cin, str);</span><br><span class="line">	<span class="keyword">for</span> (<span class="type">char</span> c : str) &#123;</span><br><span class="line">		<span class="keyword">if</span> (c == <span class="string">&#x27;)&#x27;</span>) &#123;</span><br><span class="line">			string t;</span><br><span class="line">			<span class="keyword">while</span> (s.<span class="built_in">top</span>() != <span class="string">&#x27;(&#x27;</span>) &#123;</span><br><span class="line">				t += s.<span class="built_in">top</span>();</span><br><span class="line">				s.<span class="built_in">pop</span>();</span><br><span class="line">			&#125;</span><br><span class="line">			s.<span class="built_in">pop</span>(); <span class="comment">// pop (</span></span><br><span class="line">			<span class="built_in">reverse</span>(t.<span class="built_in">begin</span>(), t.<span class="built_in">end</span>());</span><br><span class="line">			cout &lt;&lt; t &lt;&lt; endl;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">else</span> s.<span class="built_in">push</span>(c);</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="L2-2-三点共线"><a href="#L2-2-三点共线" class="headerlink" title="L2-2 三点共线"></a>L2-2 三点共线</h2><h3 id="题目描述-3"><a href="#题目描述-3" class="headerlink" title="题目描述"></a>题目描述</h3><p>给定平面上 <em>n</em> 个点的坐标 ($x_i$,$y_i$)（<em>i</em>&#x3D;1,⋯,<em>n</em>），其中 <em>y</em> 坐标只能是 0、1 或 2，是否存在三个不同的点位于一条<strong>非水平</strong>的直线上？</p>
<p>本题就请你找出所有共线的解。</p>
<h3 id="求解思路-3"><a href="#求解思路-3" class="headerlink" title="求解思路"></a>求解思路</h3><p>这题直接简单模拟一下是o(n^3^)，n&lt;&#x3D;5×10^4^，时间限制2s，1s大约可以处理10^8^，那样肯定超时，需要优化到o(n^3^)，那就需要想到把y&#x3D;2的点换一个情况存，不能在直接vector一个个存了。那就直接开个坐标数组记录一下y&#x3D;2时在某个x的情况下有没有点存在即可，因为我们这个点的x坐标是直接算出来的，不需要遍历，所以这样存就是最快的。 </p>
<h3 id="实现代码-3"><a href="#实现代码-3" class="headerlink" title="实现代码"></a>实现代码</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;bits/stdc++.h&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"><span class="keyword">typedef</span> <span class="type">long</span> <span class="type">long</span> LL;</span><br><span class="line"></span><br><span class="line"><span class="keyword">struct</span> <span class="title class_">coord</span> &#123;</span><br><span class="line">	LL x, y;</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line">vector&lt;LL&gt; a0, a1; <span class="comment">// 存x，y分别为 0 1</span></span><br><span class="line"><span class="type">bool</span> a2[<span class="number">3000100</span>];</span><br><span class="line">LL ans0 = <span class="number">0</span>, ans1 = <span class="number">0</span>, ans2 = <span class="number">0</span>, flag = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">LL n;</span><br><span class="line">LL N = <span class="number">1e6</span>;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</span><br><span class="line">	cin &gt;&gt; n;</span><br><span class="line">	<span class="keyword">for</span> (LL i = <span class="number">0</span>; i &lt; n; i++) &#123;</span><br><span class="line">		LL x, y;</span><br><span class="line">		cin &gt;&gt; x &gt;&gt; y;</span><br><span class="line">		<span class="keyword">if</span> (y == <span class="number">0</span>) a0.<span class="built_in">push_back</span>(x);</span><br><span class="line">		<span class="keyword">else</span> <span class="keyword">if</span> (y == <span class="number">1</span>) a1.<span class="built_in">push_back</span>(x);</span><br><span class="line">		<span class="keyword">else</span> <span class="keyword">if</span> (y == <span class="number">2</span>) a2[x + N] = <span class="number">1</span>;	</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	<span class="built_in">sort</span>(a0.<span class="built_in">begin</span>(), a0.<span class="built_in">end</span>()), <span class="built_in">sort</span>(a1.<span class="built_in">begin</span>(), a1.<span class="built_in">end</span>()); </span><br><span class="line">	</span><br><span class="line">	LL qian_x1, flag1 = <span class="number">0</span>;</span><br><span class="line">	<span class="keyword">for</span> (LL i = <span class="number">0</span>; i &lt; a1.<span class="built_in">size</span>(); i++) &#123;</span><br><span class="line">	    LL x1 = a1[i];</span><br><span class="line">	    <span class="keyword">if</span> (i &gt; <span class="number">0</span> &amp;&amp; a1[i<span class="number">-1</span>] == x1) <span class="keyword">continue</span>; <span class="comment">// 跳过重复的 x1</span></span><br><span class="line">	    </span><br><span class="line">	    <span class="keyword">for</span> (LL j = <span class="number">0</span>; j &lt; a0.<span class="built_in">size</span>(); j++) &#123;</span><br><span class="line">	        LL x0 = a0[j];</span><br><span class="line">	        <span class="keyword">if</span> (j &gt; <span class="number">0</span> &amp;&amp; a0[j<span class="number">-1</span>] == x0) <span class="keyword">continue</span>; <span class="comment">// 跳过重复的 x0</span></span><br><span class="line">	        </span><br><span class="line">	        LL x2 = x1 + (x1 - x0);</span><br><span class="line">	        <span class="comment">// 确保 x2 在有效范围内</span></span><br><span class="line">	        <span class="keyword">if</span> (x2 &gt;= -N &amp;&amp; x2 &lt;= N &amp;&amp; a2[x2 + N]) &#123;</span><br><span class="line">	            flag = <span class="number">1</span>;</span><br><span class="line">	            <span class="built_in">printf</span>(<span class="string">&quot;[%lld, 0] [%lld, 1] [%lld, 2]\n&quot;</span>, x0, x1, x2);</span><br><span class="line">	        &#125;</span><br><span class="line">	    &#125;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	</span><br><span class="line">	<span class="keyword">if</span> (!flag) cout &lt;&lt; <span class="number">-1</span>;</span><br><span class="line">	</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="L2-3-胖达的山头"><a href="#L2-3-胖达的山头" class="headerlink" title="L2-3 胖达的山头"></a>L2-3 胖达的山头</h2><h3 id="题目描述-4"><a href="#题目描述-4" class="headerlink" title="题目描述"></a>题目描述</h3><p>胖达是大熊猫的昵称。上图是著名的“西直门三太子”萌兰的一字马。</p>
<p>一只成年大熊猫需要有自己独立的生活区域，如果两只成年大熊猫在同一时间进入同一片区域，很可能会发生打斗事件。</p>
<p>大熊猫保护中心计划将保护区划分成若干座山头，让胖达们都过上没有冲突的安逸生活。当然如果为每位胖达分配一个山头是最理想的，但中心计划安置数十万只胖达 —— 这是个长远计划（截至2024年，世界上共有近 1900 只大熊猫），而保护区面积有限，这样做会使得每个山头面积过于局促。于是中心负责人找到了你，带着所有胖达的活跃时间表，请你帮助他们计算一下，如果让所有活跃时间段内的胖达都位于不同的山头，最少需要建设多少个山头？</p>
<h3 id="求解思路-4"><a href="#求解思路-4" class="headerlink" title="求解思路"></a>求解思路</h3><p><img src="http://img.sevin.cn/i/2025/05/12/6821ded3aa7f9.png" alt="1747050194073.png"></p>
<p>这题模拟一下就是以时间为坐标，求占用最多占用山头的时候的占用山头数量。然后就可以画出上面的黑线，然后思考怎么求答案呢？那就是只要在每次有新的熊猫占用山头的时候算一下占用数，然后把全部的这个数值取最大值即可（贪心）。</p>
<p>然后怎么维护时间的区间呢？然后就看一下数据大小，时间从从 <code>00:00:00</code> 到 <code>23:59:59</code>，那其实每一个时间点（按秒算）都可以算一个坐标了，一个数组就能存下，nice！再然后当然不能直接一个一个的点的维护区间了，不然嘎嘎超时，理所应当想到区间用差分，就可以愉快的敲代码了。</p>
<h3 id="实现代码-4"><a href="#实现代码-4" class="headerlink" title="实现代码"></a>实现代码</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;bits/stdc++.h&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"><span class="keyword">typedef</span> <span class="type">long</span> <span class="type">long</span> LL;</span><br><span class="line"><span class="keyword">typedef</span> pair&lt;LL, LL&gt; PII;</span><br><span class="line"></span><br><span class="line">vector&lt;PII&gt; a; <span class="comment">// 存输入的区间信息</span></span><br><span class="line">LL coord[<span class="number">100000</span>]; <span class="comment">// 时间的坐标系</span></span><br><span class="line">LL n, res = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">insert</span><span class="params">(LL num, LL l, LL r)</span> </span>&#123;</span><br><span class="line">	coord[l] += num, coord[r + <span class="number">1</span>] -= num;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</span><br><span class="line">	cin &gt;&gt; n;</span><br><span class="line">	<span class="keyword">for</span> (LL i = <span class="number">0</span>; i &lt; n; i++) &#123;</span><br><span class="line">		LL h1, m1, s1, h2, m2, s2;</span><br><span class="line">		<span class="built_in">scanf</span>(<span class="string">&quot;%lld:%lld:%lld %lld:%lld:%lld&quot;</span>, &amp;h1, &amp;m1, &amp;s1, &amp;h2, &amp;m2, &amp;s2);</span><br><span class="line">		LL begin = h1 * <span class="number">3600</span> + m1 * <span class="number">60</span> + s1, end = h2 * <span class="number">3600</span> + m2 * <span class="number">60</span> + s2;</span><br><span class="line">		a.<span class="built_in">push_back</span>(&#123;begin, end&#125;);</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="built_in">sort</span>(a.<span class="built_in">begin</span>(), a.<span class="built_in">end</span>());</span><br><span class="line">	<span class="keyword">for</span> (<span class="keyword">auto</span> qj : a) &#123; <span class="comment">// 区间合并到坐标系上</span></span><br><span class="line">		LL begin = qj.first, end = qj.second;</span><br><span class="line">		<span class="built_in">insert</span>(<span class="number">1</span>, begin, end);</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">for</span> (LL i = <span class="number">1</span>; i &lt; <span class="number">100000</span>; i++) &#123; <span class="comment">// 求前缀和</span></span><br><span class="line">		coord[i] += coord[i - <span class="number">1</span>];</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">for</span> (<span class="keyword">auto</span> qj : a)  &#123;<span class="comment">// 查询每个开始的点对应的数据</span></span><br><span class="line">		LL begin = qj.first;</span><br><span class="line">		res = <span class="built_in">max</span>(res, coord[begin]);</span><br><span class="line">	&#125;</span><br><span class="line">	cout &lt;&lt; res;</span><br><span class="line">	</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="L2-4-被n整除的n位数"><a href="#L2-4-被n整除的n位数" class="headerlink" title="L2-4 被n整除的n位数"></a>L2-4 被n整除的n位数</h2><h3 id="题目描述-5"><a href="#题目描述-5" class="headerlink" title="题目描述"></a>题目描述</h3><p>“被 <em>n</em> 整除的 <em>n</em> 位数”是这样定义的：记这个 <em>n</em> 位数为 $a_n$⋯$a_2$$a_1$。首先 $a_n$ 不为 0。从 $a_n$ 开始从左到右扫描每一位数字，前 1 位数（即 $a_n$）能被 1 整除，前 2 位数 $a_n$$a_{n-1}$ 能被 2 整除，以此类推…… 即前 <em>i</em> 位数能被 <em>i</em> 整除（<em>i</em>&#x3D;1,⋯,<em>n</em>）。</p>
<p>例如 34285 这个 5 位数，其前 1 位数 3 能被 1 整除；前 2 位数 34 能被 2 整除；前 3 位数 342 能被 3 整除；前 4 位数 3428 能被 4 整除；前 5 位数 34285 能被 5 整除。所以 34285 是能被 5 整除的 5 位数。</p>
<p>本题就请你对任一给定的 <em>n</em>，求出给定区间内被 <em>n</em> 整除的 <em>n</em> 位数。</p>
<p><strong>友情提示</strong>：被偶数整除的数字一定以偶数结尾；被 5 整除的数字一定以 5 或 0 结尾；被 10 整除的数字一定以 0 结尾。</p>
<h3 id="求解思路-5"><a href="#求解思路-5" class="headerlink" title="求解思路"></a>求解思路</h3><p>这题可以看到这个数字可以是从高位开始一位一位生成的，可以用<strong>dfs</strong>。然后看到题目中的一堆条件就知道肯定可以<strong>剪枝</strong>，这样优化后就能够过题了。</p>
<h3 id="实现代码-5"><a href="#实现代码-5" class="headerlink" title="实现代码"></a>实现代码</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;bits/stdc++.h&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"><span class="keyword">typedef</span> <span class="type">long</span> <span class="type">long</span> LL;</span><br><span class="line"></span><br><span class="line"><span class="type">int</span> n;</span><br><span class="line"><span class="type">long</span> <span class="type">long</span> a, b;</span><br><span class="line">vector&lt;<span class="type">long</span> <span class="type">long</span>&gt; results;</span><br><span class="line"></span><br><span class="line"><span class="comment">// DFS函数，depth表示当前处理的位数，current表示当前构造的数字</span></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">dfs</span><span class="params">(<span class="type">int</span> depth, <span class="type">long</span> <span class="type">long</span> current)</span> </span>&#123;</span><br><span class="line">    <span class="comment">// 如果已经构造了n位数</span></span><br><span class="line">    <span class="keyword">if</span> (depth == n) &#123;</span><br><span class="line">        <span class="keyword">if</span> (a &lt;= current &amp;&amp; current &lt;= b) &#123;</span><br><span class="line">            results.<span class="built_in">push_back</span>(current);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">// 确定当前位可以尝试的数字</span></span><br><span class="line">    <span class="type">int</span> start_digit = (depth == <span class="number">0</span>) ? <span class="number">1</span> : <span class="number">0</span>;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">for</span> (<span class="type">int</span> digit = start_digit; digit &lt;= <span class="number">9</span>; digit++) &#123;</span><br><span class="line">        <span class="type">long</span> <span class="type">long</span> new_num = current * <span class="number">10</span> + digit;</span><br><span class="line">        </span><br><span class="line">        <span class="comment">// 区间剪枝：检查是否可能在区间内</span></span><br><span class="line">        <span class="type">long</span> <span class="type">long</span> min_possible = new_num * <span class="built_in">pow</span>(<span class="number">10</span>, n - depth - <span class="number">1</span>);</span><br><span class="line">        <span class="keyword">if</span> (min_possible &gt; b) &#123;</span><br><span class="line">            <span class="keyword">break</span>;  <span class="comment">// 后续数字更大，直接退出</span></span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        <span class="type">long</span> <span class="type">long</span> max_possible = min_possible + <span class="built_in">pow</span>(<span class="number">10</span>, n - depth - <span class="number">1</span>) - <span class="number">1</span>;</span><br><span class="line">        <span class="keyword">if</span> (max_possible &lt; a) &#123;</span><br><span class="line">            <span class="keyword">continue</span>;  <span class="comment">// 即使后续位全是9，也小于a，跳过</span></span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        <span class="comment">// 整除性剪枝</span></span><br><span class="line">        <span class="keyword">if</span> ((depth + <span class="number">1</span>) &gt; <span class="number">0</span> &amp;&amp; new_num % (depth + <span class="number">1</span>) != <span class="number">0</span>) &#123;</span><br><span class="line">            <span class="keyword">continue</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        <span class="comment">// 尾数剪枝</span></span><br><span class="line">        <span class="keyword">if</span> ((depth + <span class="number">1</span>) % <span class="number">2</span> == <span class="number">0</span> &amp;&amp; digit % <span class="number">2</span> != <span class="number">0</span>) &#123;</span><br><span class="line">            <span class="keyword">continue</span>;  <span class="comment">// 偶数位必须是偶数结尾</span></span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> ((depth + <span class="number">1</span>) % <span class="number">5</span> == <span class="number">0</span> &amp;&amp; digit != <span class="number">0</span> &amp;&amp; digit != <span class="number">5</span>) &#123;</span><br><span class="line">            <span class="keyword">continue</span>;  <span class="comment">// 5的倍数位必须是0或5结尾</span></span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> ((depth + <span class="number">1</span>) % <span class="number">10</span> == <span class="number">0</span> &amp;&amp; digit != <span class="number">0</span>) &#123;</span><br><span class="line">            <span class="keyword">continue</span>;  <span class="comment">// 10的倍数位必须是0结尾</span></span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        <span class="comment">// 继续DFS</span></span><br><span class="line">        <span class="built_in">dfs</span>(depth + <span class="number">1</span>, new_num);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    cin &gt;&gt; n &gt;&gt; a &gt;&gt; b;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">// 检查a和b是否都是n位数</span></span><br><span class="line">    <span class="type">long</span> <span class="type">long</span> min_n_digit = <span class="built_in">pow</span>(<span class="number">10</span>, n<span class="number">-1</span>);</span><br><span class="line">    <span class="type">long</span> <span class="type">long</span> max_n_digit = <span class="built_in">pow</span>(<span class="number">10</span>, n) - <span class="number">1</span>;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">// 调整a和b到n位数的范围内</span></span><br><span class="line">    a = <span class="built_in">max</span>(a, min_n_digit);</span><br><span class="line">    b = <span class="built_in">min</span>(b, max_n_digit);</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">if</span> (a &gt; b) &#123;</span><br><span class="line">        cout &lt;&lt; <span class="string">&quot;No Solution&quot;</span> &lt;&lt; endl;</span><br><span class="line">        <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="built_in">dfs</span>(<span class="number">0</span>, <span class="number">0</span>);</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">if</span> (results.<span class="built_in">empty</span>()) &#123;</span><br><span class="line">        cout &lt;&lt; <span class="string">&quot;No Solution&quot;</span> &lt;&lt; endl;</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="keyword">for</span> (<span class="type">long</span> <span class="type">long</span> result : results) &#123;</span><br><span class="line">            cout &lt;&lt; result &lt;&lt; endl;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://blog.sevin.cn">Sevin</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://blog.sevin.cn/posts/58365/">https://blog.sevin.cn/posts/58365/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="external nofollow noreferrer" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://blog.sevin.cn" target="_blank">Sevin的小窝</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E9%A2%98%E7%9B%AE/">题目</a></div><div class="post_share"><div class="social-share" data-image="https://api.sevin.cn/api/img/ecy/%20(149).jpg" data-sites="qq,wechat,weibo,facebook,twitter"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/img/wechat.png" target="_blank"><img class="post-qr-code-img" src="/img/wechat.png" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/img/alipay.jpg" target="_blank"><img class="post-qr-code-img" src="/img/alipay.jpg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/posts/29994/" title="P3078[USACO13MAR] Poker Hands S"><img class="cover" src="https://api.sevin.cn/api/img/ecy/%20(150).jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2025-02-04</div><div class="title">P3078[USACO13MAR] Poker Hands S</div></div></a></div><div><a href="/posts/13857/" title="c&#x2F;c++语言错题记录"><img class="cover" src="https://api.sevin.cn/api/img/ecy/%20(132).jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-11-08</div><div class="title">c&#x2F;c++语言错题记录</div></div></a></div><div><a href="/posts/36872/" title="p1036选数"><img class="cover" src="https://api.sevin.cn/api/img/ecy/%20(150).jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-11-08</div><div class="title">p1036选数</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="gitalk-container"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://q.qlogo.cn/g?b=qq&amp;nk=2720269770&amp;s=640" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Sevin</div><div class="author-info__description">喜欢瞎鼓捣的Sevin！</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">42</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">36</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><a id="card-info-btn" target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/itsevin"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://home.sevin.cn/" rel="external nofollow noreferrer" target="_blank" title="Home"><i class="fa-solid fa-house"></i></a><a class="social-icon" href="https://github.com/itsevin" rel="external nofollow noreferrer" target="_blank" title="GitHub"><i class="fab fa-github"></i></a><a class="social-icon" href="https://blog.csdn.net/m0_62568363" rel="external nofollow noreferrer" target="_blank" title="CSDN"><i class="fa-solid fa-c"></i></a><a class="social-icon" href="https://space.bilibili.com/1961300960" rel="external nofollow noreferrer" target="_blank" title="Bili"><i class="fa-brands fa-bilibili"></i></a><a class="social-icon" href="mailto:itsevin@qq.com" rel="external nofollow noreferrer" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="https://blog.sevin.cn/feed.xml" target="_blank" title="RSS"><i class="fas fa-rss"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">欢迎来Sevin的小窝窝取暖QWQ</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content is-expand"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#2025%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1%E5%A4%A9%E6%A2%AF%E8%B5%9B%E8%A1%A5%E9%A2%98%E6%8A%A5%E5%91%8A"><span class="toc-number">1.</span> <span class="toc-text">2025程序设计天梯赛补题报告</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#L1-6-%E8%BF%99%E4%B8%8D%E6%98%AF%E5%AD%97%E7%AC%A6%E4%B8%B2%E9%A2%98"><span class="toc-number">1.1.</span> <span class="toc-text">L1-6 这不是字符串题</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%A2%98%E7%9B%AE%E6%8F%8F%E8%BF%B0"><span class="toc-number">1.1.1.</span> <span class="toc-text">题目描述</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%B1%82%E8%A7%A3%E6%80%9D%E8%B7%AF"><span class="toc-number">1.1.2.</span> <span class="toc-text">求解思路</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#insert"><span class="toc-number">1.1.2.1.</span> <span class="toc-text">insert</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#erase"><span class="toc-number">1.1.2.2.</span> <span class="toc-text">erase</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%9E%E7%8E%B0%E4%BB%A3%E7%A0%81"><span class="toc-number">1.1.3.</span> <span class="toc-text">实现代码</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#L1-7-%E5%A4%A7%E5%B9%82%E6%95%B0"><span class="toc-number">1.2.</span> <span class="toc-text">L1-7 大幂数</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%A2%98%E7%9B%AE%E6%8F%8F%E8%BF%B0-1"><span class="toc-number">1.2.1.</span> <span class="toc-text">题目描述</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%B1%82%E8%A7%A3%E6%80%9D%E8%B7%AF-1"><span class="toc-number">1.2.2.</span> <span class="toc-text">求解思路</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%9E%E7%8E%B0%E4%BB%A3%E7%A0%81-1"><span class="toc-number">1.2.3.</span> <span class="toc-text">实现代码</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#L2-1-%E7%AE%97%E5%BC%8F%E6%8B%86%E8%A7%A3"><span class="toc-number">1.3.</span> <span class="toc-text">L2-1 算式拆解</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%A2%98%E7%9B%AE%E6%8F%8F%E8%BF%B0-2"><span class="toc-number">1.3.1.</span> <span class="toc-text">题目描述</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%B1%82%E8%A7%A3%E6%80%9D%E8%B7%AF-2"><span class="toc-number">1.3.2.</span> <span class="toc-text">求解思路</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%9E%E7%8E%B0%E4%BB%A3%E7%A0%81-2"><span class="toc-number">1.3.3.</span> <span class="toc-text">实现代码</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#L2-2-%E4%B8%89%E7%82%B9%E5%85%B1%E7%BA%BF"><span class="toc-number">1.4.</span> <span class="toc-text">L2-2 三点共线</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%A2%98%E7%9B%AE%E6%8F%8F%E8%BF%B0-3"><span class="toc-number">1.4.1.</span> <span class="toc-text">题目描述</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%B1%82%E8%A7%A3%E6%80%9D%E8%B7%AF-3"><span class="toc-number">1.4.2.</span> <span class="toc-text">求解思路</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%9E%E7%8E%B0%E4%BB%A3%E7%A0%81-3"><span class="toc-number">1.4.3.</span> <span class="toc-text">实现代码</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#L2-3-%E8%83%96%E8%BE%BE%E7%9A%84%E5%B1%B1%E5%A4%B4"><span class="toc-number">1.5.</span> <span class="toc-text">L2-3 胖达的山头</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%A2%98%E7%9B%AE%E6%8F%8F%E8%BF%B0-4"><span class="toc-number">1.5.1.</span> <span class="toc-text">题目描述</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%B1%82%E8%A7%A3%E6%80%9D%E8%B7%AF-4"><span class="toc-number">1.5.2.</span> <span class="toc-text">求解思路</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%9E%E7%8E%B0%E4%BB%A3%E7%A0%81-4"><span class="toc-number">1.5.3.</span> <span class="toc-text">实现代码</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#L2-4-%E8%A2%ABn%E6%95%B4%E9%99%A4%E7%9A%84n%E4%BD%8D%E6%95%B0"><span class="toc-number">1.6.</span> <span class="toc-text">L2-4 被n整除的n位数</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%A2%98%E7%9B%AE%E6%8F%8F%E8%BF%B0-5"><span class="toc-number">1.6.1.</span> <span class="toc-text">题目描述</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%B1%82%E8%A7%A3%E6%80%9D%E8%B7%AF-5"><span class="toc-number">1.6.2.</span> <span class="toc-text">求解思路</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%9E%E7%8E%B0%E4%BB%A3%E7%A0%81-5"><span class="toc-number">1.6.3.</span> <span class="toc-text">实现代码</span></a></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/posts/42943/" title="搜索算法讲解"><img src="https://api.sevin.cn/api/img/ecy/%20(81).jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="搜索算法讲解"/></a><div class="content"><a class="title" href="/posts/42943/" title="搜索算法讲解">搜索算法讲解</a><time datetime="2025-07-06T21:31:11.000Z" title="发表于 2025-07-06 21:31:11">2025-07-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/54030/" title="哈夫曼编码：数据压缩的优雅艺术"><img src="https://api.sevin.cn/api/img/ecy/%20(149).jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="哈夫曼编码：数据压缩的优雅艺术"/></a><div class="content"><a class="title" href="/posts/54030/" title="哈夫曼编码：数据压缩的优雅艺术">哈夫曼编码：数据压缩的优雅艺术</a><time datetime="2025-05-19T20:32:07.000Z" title="发表于 2025-05-19 20:32:07">2025-05-19</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/58365/" title="2025程序设计天梯赛补题报告"><img src="https://api.sevin.cn/api/img/ecy/%20(149).jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="2025程序设计天梯赛补题报告"/></a><div class="content"><a class="title" href="/posts/58365/" title="2025程序设计天梯赛补题报告">2025程序设计天梯赛补题报告</a><time datetime="2025-05-16T22:33:40.000Z" title="发表于 2025-05-16 22:33:40">2025-05-16</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('/img/footer.jpg')"><div id="footer-wrap"><div class="copyright">&copy;2025  <i id="heartbeat" class="fa fas fa-heartbeat"></i> Sevin</div><div class="footer_custom_text"><!DOCTYPE html><html><head><meta charset="utf-8"><title></title></head><body><div>鲲鹏九万里 直上云海巅</div><p><a style="margin-inline:5px"target="_blank"href="https://beian.miit.gov.cn/#/Integrated/index/" rel="external nofollow noreferrer"><img src="https://img.shields.io/badge/%E9%97%BDICP%E5%A4%87-2022004931%E5%8F%B7--1-e1d492?style=flat&logo="title="ICP备案"></a><a style="margin-inline:5px"target="_blank"href="http://creativecommons.org/licenses/by-nc-sa/4.0/" rel="external nofollow noreferrer"><img src="https://img.shields.io/badge/Copyright-BY--NC--SA%204.0-d42328?style=flat&logo=Claris"title="本站采用知识共享署名-非商业性使用-相同方式共享4.0国际许可协议进行许可"></a></p><!-- hexo injector body_end start --> <script data-pjax>if(document.getElementById('recent-posts') && location.pathname =='/'){
    
    var parent = document.getElementById('recent-posts');
    var child = '<div class="recent-post-item" style="height: auto;width: 100%"><div class="blog-slider swiper-container-fade swiper-container-horizontal" id="swiper_container"><div class="blog-slider__wrp swiper-wrapper" style="transition-duration: 0ms"><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms"><div class="blog-slider__img"><img src="https://img.sevin.cn/i/2023/10/07/6521756081d56.jpg" alt="https://img.sevin.cn/i/2023/10/07/6521756081d56.jpg"/></div><div class="blog-slider__content"><span class="blog-slider__code">2023-10-07</span><a class="blog-slider__title" href="posts/35833/">Sevin的自我介绍</a><div class="blog-slider__text">关于Sevin的……</div><a class="blog-slider__button" href="posts/35833/">详情</a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms"><div class="blog-slider__img"><img src="https://api.sevin.cn/api/img/ecy/%20(128).jpg" alt="https://api.sevin.cn/api/img/ecy/%20(128).jpg"/></div><div class="blog-slider__content"><span class="blog-slider__code">2022-08-14</span><a class="blog-slider__title" href="posts/24760/">超简单随机文本API制作教程</a><div class="blog-slider__text">随机文本API制作教程，超简单，包会！</div><a class="blog-slider__button" href="posts/24760/">详情</a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms"><div class="blog-slider__img"><img src="https://api.sevin.cn/api/img/ecy/%20(121).jpg" alt="https://api.sevin.cn/api/img/ecy/%20(121).jpg"/></div><div class="blog-slider__content"><span class="blog-slider__code">2022-08-14</span><a class="blog-slider__title" href="posts/20775/">超简单随机图片API制作教程</a><div class="blog-slider__text">随机图片API制作教程，超简单，包会！</div><a class="blog-slider__button" href="posts/20775/">详情</a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms"><div class="blog-slider__img"><img src="https://api.sevin.cn/api/img/ecy/%20(147).jpg" alt="https://api.sevin.cn/api/img/ecy/%20(147).jpg"/></div><div class="blog-slider__content"><span class="blog-slider__code">2022-08-13</span><a class="blog-slider__title" href="posts/39795/">nonebot2调用图片API发送随机图片</a><div class="blog-slider__text">nonebot2调用图片API发送随机图片插件编写指南</div><a class="blog-slider__button" href="posts/39795/">详情</a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms"><div class="blog-slider__img"><img src="https://api.sevin.cn/api/img/ecy/%20(125).jpg" alt="https://api.sevin.cn/api/img/ecy/%20(125).jpg"/></div><div class="blog-slider__content"><span class="blog-slider__code">2022-08-26</span><a class="blog-slider__title" href="posts/8797/">nonebot2调用json格式图片API发送随机图片</a><div class="blog-slider__text">nonebot2调用json格式图片API发送随机图片教程以及插件模板，满满干货！</div><a class="blog-slider__button" href="posts/8797/">详情</a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms"><div class="blog-slider__img"><img src="http://img.sevin.cn/i/2023/06/07/647fef3307e50.jpg" alt="http://img.sevin.cn/i/2023/06/07/647fef3307e50.jpg"/></div><div class="blog-slider__content"><span class="blog-slider__code">2022-03-30</span><a class="blog-slider__title" href="posts/39793/">使用手机软件Bluino Loader通过蓝牙编程、烧录Arduino</a><div class="blog-slider__text">一些小伙伴或许因为没有电脑又想学习Arduino而犯愁，但是在这片文章中我将会带领大家来完美解决这个问题，我们将使用手机软件Bluino Loader通过蓝牙编程、烧录Arduino</div><a class="blog-slider__button" href="posts/39793/">详情</a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms"><div class="blog-slider__img"><img src="https://api.sevin.cn/api/img/ecy/%20(132).jpg" alt="https://api.sevin.cn/api/img/ecy/%20(132).jpg"/></div><div class="blog-slider__content"><span class="blog-slider__code">2022-08-13</span><a class="blog-slider__title" href="posts/39700/">nonebot2调用文本API发送随机图片</a><div class="blog-slider__text">nonebot2调用文本API发送随机文本插件编写指南</div><a class="blog-slider__button" href="posts/39700/">详情</a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms"><div class="blog-slider__img"><img src="https://api.sevin.cn/api/img/ecy/%20(132).jpg" alt="https://api.sevin.cn/api/img/ecy/%20(132).jpg"/></div><div class="blog-slider__content"><span class="blog-slider__code">2022-08-26</span><a class="blog-slider__title" href="posts/26627/">nonebot2调用json格式文本API发送随机文本</a><div class="blog-slider__text">nonebot2调用json格式文本API发送随机文本教程以及插件模板，满满干货！</div><a class="blog-slider__button" href="posts/26627/">详情</a></div></div></div><div class="blog-slider__pagination swiper-pagination-clickable swiper-pagination-bullets"></div></div></div>';
    console.log('已挂载swiper')
    parent.insertAdjacentHTML("afterbegin",child)}
     </script>
<script data-pjax src="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-swiper/swiper/swiper.min.js"></script>
<script data-pjax src="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-swiper@0.18/swiper/swiperindex.js"></script>
<style></style><!-- hexo injector body_end end --></body></html></div></div><head><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/HCLonely/images@master/others/heartbeat.min.css"></head></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>if (!window.MathJax) {
  window.MathJax = {
    tex: {
      inlineMath: [ ['$','$'], ["\\(","\\)"]],
      tags: 'ams'
    },
    chtml: {
      scale: 1.2
    },
    options: {
      renderActions: {
        findScript: [10, doc => {
          for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
            const display = !!node.type.match(/; *mode=display/)
            const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
            const text = document.createTextNode('')
            node.parentNode.replaceChild(text, node)
            math.start = {node: text, delim: '', n: 0}
            math.end = {node: text, delim: '', n: 0}
            doc.math.push(math)
          }
        }, ''],
        insertScript: [200, () => {
          document.querySelectorAll('mjx-container:not\([display]\)').forEach(node => {
            const target = node.parentNode
            if (target.nodeName.toLowerCase() === 'li') {
              target.parentNode.classList.add('has-jax')
            } else {
              target.classList.add('has-jax')
            }
          });
        }, '', false]
      }
    }
  }
  
  const script = document.createElement('script')
  script.src = 'https://cdn.jsdelivr.net/npm/mathjax/es5/tex-mml-chtml.min.js'
  script.id = 'MathJax-script'
  script.async = true
  document.head.appendChild(script)
} else {
  MathJax.startup.document.state(0)
  MathJax.texReset()
  MathJax.typeset()
}</script><script>function addGitalkSource () {
  const ele = document.createElement('link')
  ele.rel = 'stylesheet'
  ele.href= 'https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.css'
  document.getElementsByTagName('head')[0].appendChild(ele)
}

function loadGitalk () {
  function initGitalk () {
    var gitalk = new Gitalk(Object.assign({
      clientID: '8d3733d4a7331717c73b',
      clientSecret: 'e202858cc2b0404eea2852a3fa77fad762a5cd28',
      repo: 'comment_blog',
      owner: 'itsevin',
      admin: ['itsevin'],
      id: '94a77709b115bcca13788aae48aa459e',
      updateCountCallback: commentCount
    },null))

    gitalk.render('gitalk-container')
  }

  if (typeof Gitalk === 'function') initGitalk()
  else {
    addGitalkSource()
    getScript('https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.js').then(initGitalk)
  }
}

function commentCount(n){
  let isCommentCount = document.querySelector('#post-meta .gitalk-comment-count')
  if (isCommentCount) {
    isCommentCount.innerHTML= n
  }
}

if ('Gitalk' === 'Gitalk' || !false) {
  if (false) btf.loadComment(document.getElementById('gitalk-container'), loadGitalk)
  else loadGitalk()
} else {
  function loadOtherComment () {
    loadGitalk()
  }
}</script></div><div class="aplayer no-destroy" data-id="60198" data-server="netease" data-type="playlist" data-fixed="true" data-autoplay="false"> </div><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-nest.min.js"></script><script id="click-show-text" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/click-show-text.min.js" data-mobile="false" data-text="富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善,歇会" data-fontsize="15px" data-random="false" async="async"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/metingjs/dist/Meting.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>